<template>
	<view class="container">
		<view class="intro">本项目已包含uni ui组件，无需import和注册，可直接使用。在代码区键入字母u，即可通过代码助手列出所有可用组件。光标置于组件名称处按F1，即可查看组件文档。</view>
		<button @click="goAbout">about123</button>
		<navigator url="/pages/test/index">test</navigator>
        <view>
            <input class="uni-input" placeholder="自动获得焦点" v-model="msg" @confirm="msgComfirm"/>
            <image src="@/static/c1.png"></image>
            <image :src="url" mode=""></image>
        </view>
        <button @click="eventTest">evetn test</button>
        <my-view></my-view>
	</view>
</template>

<script>
	import {default_url, another_url} from "./config"
	export default {
		data() {
			return {
				href: default_url,
                msg: '1',
                url: '../../static/c2.png'
			}
		},
		methods: {
			goAbout() {
        
        // let params = {
        //   name: 'RH40-91Q000002A0海外ROPS&OPG铭牌(F)',
        //   nameList: ['RH40-91Q000002A0海外ROPS&OPG铭牌(F)'],
        //   nameObj: {
        //     a: 'RH40-91Q000002A0海外ROPS&OPG铭牌(F)'
        //   }
        // }
        
        let params = {
          nameList: []
        }
        for(let i=0;i<5;i++) {
          params.nameList.push('RH40-91Q000002A0海外ROPS&OPG铭牌(F)')
        }
        
        console.log('--json', JSON.stringify(params));
        
        let encoded = encodeURIComponent(JSON.stringify(params))
        
        let str = JSON.stringify(params)
        // console.log('---2', encoded);
        
        // uni.setStorageSync('ttt', params)
        
        // uni.navigateTo({
        //   url: "/pages/about/index"
        // })
        
				uni.navigateTo({
					url:"/pages/about/index?options=" + encoded
				})
                // uni.$emit("global-bus", { num: 123})
			},
            msgComfirm() {
                this.url = `../../static/c${this.msg}.png`
            },
            eventTest() {
                uni.$off("global-bus", this.globalEventHandler)
            },
            globalEventHandler(data) {
                console.log('自己发出自己监听', data)
            }
		},
        onInit() {
            console.log('index init')
        },
        onLoad() {
            console.log("index load")
        },
        onReady() {
            console.log("index ready")
            
            uni.$on("global-bus", this.globalEventHandler)
        },
        onShow() {
            console.log("index show")
            const app = getApp()
            console.log('==app.globalData', app.globalData);
            app.appMethod()
        },
        onResize() {
            console.log('index resize')
        }
        
	}
</script>

<style>
	.container {
		padding: 20px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
